package com.hrbxlh.action;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.hrbxlh.actionImpl.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


import com.fasterxml.jackson.databind.ObjectMapper;
import com.hrbxlh.util.ConfigFileUtil;
import com.hrbxlh.util.DateUtil;
import com.hrbxlh.util.SessionValues;

/**
 * -------------------------------------------------------
 * Copyright (c) 2017, 鑫联华信息科技股份有限公司
 * All rights reserved.
 * FileName：MyCourse.java
 * Description：我的课程action类
 * History：
 * Date           Author               Desc
 * 2017.4.5		  xzx                 建立
 * -------------------------------------------------------
 */

@Controller
public class MyCourseAction {

	@Autowired
	@Qualifier("myCourseActionImpl")
	private MyCourseActionImpl myCourseActionImpl;

	@Autowired
	@Qualifier("courseActionImpl")
	private CourseActionImpl courseActionImpl;

	@Autowired
	@Qualifier("chapterActionImpl")
	private ChapterActionImpl chapterActionImpl;

	@Autowired
	@Qualifier("relationActionImpl")
	private RelationActionImpl relationActionImpl;

	@Autowired
	@Qualifier("homeworkTestActionImpl")
	private HomeworkTestActionImpl homeworkTestActionImpl;

	@Autowired
	@Qualifier("memberActionImpl")
	private MemberActionImpl memberActionImpl;



	/**
	 * @description 获取我的消息信息
	 * */
	@RequestMapping(value = "/getMyNoticeList", method = RequestMethod.POST)
	public void getMyNoticeList(HttpServletRequest request, HttpServletResponse response)   {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//获取我的消息
		List<Map<String, Object>> noticeList  = null;
		//日志信息
		Logger logger = Logger.getLogger(CourseAction.class.getName());
		try {
			noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			resultMap.put("result","success");
			courseActionImpl.responseStream(response, new ObjectMapper().writeValueAsString(resultMap));
		} catch (Exception e) {
			e.printStackTrace();
			resultMap.put("result","fail");
			logger.error("获取我的消息异常getMyNoticeList", e);
			try {
				courseActionImpl.responseStream(response, new ObjectMapper().writeValueAsString(resultMap));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}


	/**
	 * @description 跳转到我的课程页面（教师、学生）
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/skipMyCourse", method = RequestMethod.POST)
	public void skipMyCourse(HttpServletRequest request, HttpServletResponse response)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			resultMap = sessionValues;
			//获取我的课程信息
			List<Map<String, Object>> courseList = myCourseActionImpl.getMyCourse(resultMap);
			resultMap.put("courseList", courseList);
			//获取课程表信息
			List<Map<String, Object>> courseTabList = myCourseActionImpl.getCouseTab(resultMap);
			resultMap.put("courseTabList", courseTabList);
			//获取当前星期全部日期从周一到周日
			List<String> dateList = DateUtil.dateToWeek(new Date());
			resultMap.put("dateList", dateList);
			resultMap.put("roleId", resultMap.get("roleId"));
			resultMap.put("result", "success");
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("跳转我的课程页面出现异常skipMyCourse", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @description 获取上一周或下一周的课程表
	 * @param request
	 * @param response
	 * @return  课表信息
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getCourseTabAjax", method = RequestMethod.POST)
	public void  getCourseTabAjax (HttpServletResponse response, HttpServletRequest request, String jsonStr)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			resultMap = sessionValues;
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			//获取当前星期全部日期从周一到周日
			List<String> dateList = DateUtil.dateToWeek(sdf.parse((String)paramMap.get("date")));
			resultMap.put("dateList", dateList);
			//获取课表信息
			List<Map<String, Object>> courseTabList = myCourseActionImpl.getTabList(resultMap);
			resultMap.put("courseTabList", courseTabList);
			resultMap.put("result","success");
		} catch (Exception e) {
			resultMap.put("result","fail");
			e.printStackTrace();
			logger.error("查询课程表出现异常getCourseTabAjax", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**20180227商莹修改---动态判断教师是否有下载文件权限
	 * @description 在我的课程点击某课程进入的课程详情页面 (老师学生走一个action)
	 * @param request
	 * @param response
	 * @param jsonStr 需要课程id
	 * @return

	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/skipCourseStudyDetail", method = RequestMethod.POST)
	public void skipCourseStudyDetail(String jsonStr, HttpServletRequest request, HttpServletResponse response)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			sessionValues.put("courseId", paramMap.get("courseId"));
			//获取登录人学习了的章节信息
			List<Map<String, Object>> studyList = courseActionImpl.getMyStudyChapterList(sessionValues);
			resultMap.put("studyList", studyList);
			//获取课程详细信息
			Map<String, Object> courseDetail = courseActionImpl.getCourseDetail(sessionValues,request);
			resultMap.put("courseDetail", courseDetail);
			//获取学习了几个章节的进度信息
			Map<String, Object> studyProcess = courseActionImpl.getMyStudyProcess(sessionValues);
			resultMap.put("process", studyProcess.get("process"));
			//获取课程章节信息
			List<Map<String, Object>> chapterList = chapterActionImpl.getCourseChapterNotFileInfo(sessionValues);
			resultMap.put("chapterList", chapterList);
			//获取文件前缀
			String[] keysArray = {"server_address", "project_name"};
			Map<String, Object> urlmap = ConfigFileUtil.getFileMessage("UtilFile.properties", keysArray);
			String url = (String)urlmap.get("server_address")+(String)urlmap.get("project_name")+"upload/course/";

			String stuUrl = String.valueOf(urlmap.get("server_address"))+String.valueOf(urlmap.get("project_name"))+"upload/stuwork/";

			resultMap.put("stuUrl", stuUrl);
			resultMap.put("url", url);
			resultMap.put("roleId", sessionValues.get("roleId"));
			//存入进页面的标识，没有就是正常1是提交作业成功进来的
			//resultMap.put("pageMark", paramMap.get("pageMark"));
			//如果是学生，需要查询这个课，这个学生所在班级的老师id
			Map<String, Object> teacherIdMap = relationActionImpl.getMyTeacherByCourseId(sessionValues);
			resultMap.put("teacherId", teacherIdMap.get("stuorteaId"));
			//20180227商莹改获取当前登陆人是否有下载文件权限
			Map<String, Object> loginInoMap = memberActionImpl.getMemberByStuorteaId(String.valueOf(sessionValues.get("stuorteaId")));
			Map<String,Object>  memberMap = (Map<String, Object>) loginInoMap.get("memberMap");
			resultMap.put("donwload_juirs",memberMap.get("donwload_juirs"));
			resultMap.put("result", "success");
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("跳转课程学习页面出现异常skipCourseStudyDetail", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}


	/**20180227商莹修改---动态判断教师是否有下载文件权限
	 * @description 在我的课程点击某课程进入的课程详情页面,通过chapterId获取当前人每个章节的详细信息 (老师学生走一个action)
	 * @param request
	 * @param response
	 * @param jsonStr 需要课程id
	 * @return

	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/skipCourseStudyDetailByChpterId", method = RequestMethod.POST)
	public void skipCourseStudyDetailByChpterId(String jsonStr, HttpServletRequest request, HttpServletResponse response)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			sessionValues.put("chapterId", paramMap.get("chapterId"));
			sessionValues.put("courseId", paramMap.get("courseId"));
			sessionValues.put("chapterNum",paramMap.get("chapterNum"));
			//获取登录人学习了的章节信息
			/*List<Map<String, Object>> studyList = courseActionImpl.getMyStudyChapterList(sessionValues);
			resultMap.put("studyList", studyList);*/
			//获取课程详细信息
			Map<String, Object> courseDetail = courseActionImpl.getCourseDetail(sessionValues,request);
			resultMap.put("courseDetail", courseDetail);
			//获取学习了几个章节的进度信息
			/*Map<String, Object> studyProcess = courseActionImpl.getMyStudyProcess(sessionValues);
			resultMap.put("process", studyProcess.get("process"));*/
			//获取课程章节信息
			Map<String, Object> chapterMap = chapterActionImpl.getCourseChapterNotFileInfoByCourseIdAndChpIterd(sessionValues);
			resultMap.put("chapterMsg", chapterMap);
			//获取文件前缀
			String[] keysArray = {"server_address", "project_name"};
			Map<String, Object> urlmap = ConfigFileUtil.getFileMessage("UtilFile.properties", keysArray);
			String url = (String)urlmap.get("server_address")+(String)urlmap.get("project_name")+"upload/course/";
			String stuUrl = (String)urlmap.get("server_address")+(String)urlmap.get("project_name")+"upload/homeworkModel/";

			resultMap.put("url", url);
			resultMap.put("stuUrl", stuUrl);
			resultMap.put("roleId", sessionValues.get("roleId"));
			//存入进页面的标识，没有就是正常1是提交作业成功进来的
			//resultMap.put("pageMark", paramMap.get("pageMark"));
			//如果是学生，需要查询这个课，这个学生所在班级的老师id
			Map<String, Object> teacherIdMap = relationActionImpl.getMyTeacherByCourseId(sessionValues);
			resultMap.put("teacherId", teacherIdMap.get("stuorteaId"));
			//20180227商莹改获取当前登陆人是否有下载文件权限
			Map<String, Object> loginInoMap = memberActionImpl.getMemberByStuorteaId(String.valueOf(sessionValues.get("stuorteaId")));
			Map<String,Object>  memberMap = (Map<String, Object>) loginInoMap.get("memberMap");
			resultMap.put("donwload_juirs",memberMap.get("donwload_juirs"));
			resultMap.put("result", "success");
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("跳转课程学习页面出现异常skipCourseStudyDetailByChpterId", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**20180227商莹修改---动态判断教师是否有下载文件权限
	 * @description 在我的课程点击某课程进入的课程详情页面 (老师学生走一个action)
	 * @param request
	 * @param response
	 * @param jsonStr 需要课程id
	 * @return

	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/skipCourseStudyDetailByChapterId", method = RequestMethod.POST)
	public void skipCourseStudyDetailByChapterId(String jsonStr, HttpServletRequest request, HttpServletResponse response)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			sessionValues.put("courseId", paramMap.get("courseId"));
			//获取登录人学习了的章节信息
			List<Map<String, Object>> studyList = courseActionImpl.getMyStudyChapterList(sessionValues);
			resultMap.put("studyList", studyList);
			//获取课程详细信息
			Map<String, Object> courseDetail = courseActionImpl.getCourseDetail(sessionValues,request);
			resultMap.put("courseDetail", courseDetail);
			//获取学习了几个章节的进度信息
			Map<String, Object> studyProcess = courseActionImpl.getMyStudyProcess(sessionValues);
			resultMap.put("process", studyProcess.get("process"));
			//获取课程章节信息
			List<Map<String, Object>> chapterList = chapterActionImpl.getCourseChapter(sessionValues);
			resultMap.put("chapterList", chapterList);
			//获取文件前缀
			String[] keysArray = {"server_address", "project_name"};
			Map<String, Object> urlmap = ConfigFileUtil.getFileMessage("UtilFile.properties", keysArray);
			String url = (String)urlmap.get("server_address")+(String)urlmap.get("project_name")+"upload/course/";
			resultMap.put("url", url);
			resultMap.put("roleId", sessionValues.get("roleId"));
			//存入进页面的标识，没有就是正常1是提交作业成功进来的
			//resultMap.put("pageMark", paramMap.get("pageMark"));
			//如果是学生，需要查询这个课，这个学生所在班级的老师id
			Map<String, Object> teacherIdMap = relationActionImpl.getMyTeacherByCourseId(sessionValues);
			resultMap.put("teacherId", teacherIdMap.get("stuorteaId"));
			//20180227商莹改获取当前登陆人是否有下载文件权限
			Map<String, Object> loginInoMap = memberActionImpl.getMemberByStuorteaId(String.valueOf(sessionValues.get("stuorteaId")));
			Map<String,Object>  memberMap = (Map<String, Object>) loginInoMap.get("memberMap");
			resultMap.put("donwload_juirs",memberMap.get("donwload_juirs"));
			resultMap.put("result", "success");
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("跳转课程学习页面出现异常skipCourseStudyDetail", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @description 进入虚拟机环境的action
	 * 参数为课程id　chapternum id
	 * 带值：虚拟机信息、实验手册、视频信息、文件前缀、笔记信息、实验报告信息、实验报告评价信息
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/skipTestEnvirunmentList", method = RequestMethod.POST)
	public void skipTestEnvirunmentList(String jsonStr,HttpServletRequest request, HttpServletResponse response)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值 
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//通过课程，章节，查询课程课件信息
			Map<String, Object> chapterMsg = courseActionImpl.getChapterByCourseId(paramMap,request);
			resultMap.put("chapterMsg", chapterMsg);
			//文件前缀
			//获取文件前缀
			String[] keysArray = {"server_address", "project_name","access_server_address"};
			Map<String, Object> urlmap = ConfigFileUtil.getFileMessage("UtilFile.properties", keysArray);
			String url = (String)urlmap.get("server_address")+(String)urlmap.get("project_name")+"upload/course/";
			String stuUrl = (String)urlmap.get("server_address")+(String)urlmap.get("project_name")+"upload/stuwork/";
			resultMap.put("stuUrl",stuUrl);
			resultMap.put("url", url);
			resultMap.put("server_address" ,urlmap.get("server_address"));
			resultMap.put("access_server_address" ,urlmap.get("access_server_address"));
			resultMap.put("project_name" ,urlmap.get("project_name"));
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			resultMap.put("result", "success");
			//获取登录人的虚机信息
			//List<Map<String, Object>> virtualAddressList = myCourseActionImpl.getMyvirtualAddress(sessionValues);
			//resultMap.put("virtualAddressList", virtualAddressList);
			//获取这个学生这个课，这个章节的试验评价
			Map<String, Object> testAssign = myCourseActionImpl.getMyTestAssign(paramMap, request);
			if(testAssign!=null){
				if(testAssign.size()!=0){
					resultMap.put("testAssign", testAssign);
				}else{
					resultMap.put("testAssign", null);
				}
			}

			//视频名称
			resultMap.put("videoName", paramMap.get("videoName"));
			paramMap.put("stuorteaId", sessionValues.get("stuorteaId"));
			//获取这个人这个课这个章节数的实验笔记信息
			Map<String, Object> noteMap = homeworkTestActionImpl.getNoteById(paramMap);
			resultMap.put("note", noteMap);
			resultMap.put("chapterNum", paramMap.get("chapterNum"));
			//获取这个人的这个课这个章节的实验类型的实验信息
			//paramMap.put("taskType", 2);
			//Map<String, Object> taskMap = homeworkTestActionImpl.getStuTask(paramMap);
			Map<String, Object> taskMap = homeworkTestActionImpl.getStuTestHistory(paramMap);
			if(taskMap != null){
				resultMap.put("taskMsg", taskMap.get("expreHtml"));
			}
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("跳转实验环境页面出现异常skipTestEnvirunmentList", e);
		} finally {
			try {
				courseActionImpl.responseStream(response,  mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @description 清空进度信息(教师)
	 * @param request
	 * @param response
	 * @param jsonStr 课程id
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/emptyProcess", method = RequestMethod.POST)
	public void  emptyProcess (HttpServletResponse response, HttpServletRequest request, String jsonStr)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"stuorteaId"}, request, "userMsg");
			sessionValues.put("courseId", paramMap.get("courseId"));
			//清空进度信息
			boolean result = courseActionImpl.emptyProcess(sessionValues);
			String resultMark = (result) ? "success" : "fail";
			resultMap.put("result", resultMark);
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("清除进度出现异常emptyProcess", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**20180703改--增加进入课程次数
	 * @description 添加进度信息（教师与学生）
	 * @param request
	 * @param response
	 * @param jsonStr  课程id
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/addProcess", method = RequestMethod.POST)
	public void  addProcess (HttpServletResponse response, HttpServletRequest request, String jsonStr)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"stuorteaId"}, request, "userMsg");
			sessionValues.put("courseId", paramMap.get("courseId"));
			sessionValues.put("chapterNum", paramMap.get("chapterNum"));
			//添加进度信息
			boolean result = courseActionImpl.addProcess(sessionValues);
			String resultMark = (result) ? "success" : "fail";
			resultMap.put("result", resultMark);
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("添加进度信息出现异常addProcess", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}


	/**20180703改--增加阅读课件、进入实验环境的次数、
	 * @description 添加进度信息（教师与学生）
	 * @param request mark 1阅读课件 2进入实验环境  courseId
	 * @param response
	 * @param jsonStr
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/addCourseOrExpreCount", method = RequestMethod.POST)
	public void  addCourseOrExpreCount (HttpServletResponse response, HttpServletRequest request, String jsonStr)   {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"stuorteaId"}, request, "userMsg");
			sessionValues.put("mark",paramMap.get("mark"));
			sessionValues.put("courseId",paramMap.get("courseId"));
			//添加进度信息
			boolean result = courseActionImpl.addCourseOrExpreCount(sessionValues);
			String resultMark = (result) ? "success" : "fail";
			resultMap.put("result", resultMark);
		} catch (Exception e) {
			resultMap.put("result", "fail");
			e.printStackTrace();
			logger.error("添加进度信息出现异常addProcess", e);
		} finally {
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(resultMap));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @description 学生主页统计
	 * */
	@RequestMapping(value = "/stuMainCensus", method = RequestMethod.POST)
	public void  stuMainCensus (String jsonStr, HttpServletResponse response, HttpServletRequest request) {
		myCourseActionImpl.stuMainCensus(jsonStr, request, response);
	}

	/**
	 * @description 获取某个学生正在学习的全部课程
	 * //list 结果集合  courseId课程id courseName课程名 result 结果 success成功fail失败 failMsg失败信息
	 * */
	@RequestMapping(value = "/stuStudyCourses", method = RequestMethod.POST)
	public void  stuStudyCourses (HttpServletResponse response, HttpServletRequest request) {
		myCourseActionImpl.stuStudyCourses(request, response);
	}

	/**
	 * @description 教师主页统计
	 * */
	@RequestMapping(value = "/teacherMainCensus", method = RequestMethod.POST)
	public void  teacherMainCensus (HttpServletResponse response, HttpServletRequest request, String jsonStr) {
		myCourseActionImpl.teacherMainCensus(jsonStr, request, response);
	}

	/**
	 * @description 教师教的所有课程信息
	 * result 结果 success成功fail失败 failMsg失败信息  courseList  courseId课程id   courseName课程名
	 * */
	@RequestMapping(value = "/getTeacherTeachCourses", method = RequestMethod.POST)
	public void  getTeacherTeachCourses (HttpServletResponse response,HttpServletRequest request) {
		Map<String, Object> map = new HashMap<String, Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			map.put("stuorteaId", new SessionValues().getSessionValues(new String[] {"stuorteaId"}, request, "userMsg").get("stuorteaId"));
			List<Map<String, Object>> courseList = courseActionImpl.getTeaTeachCourse(map);
			map.put("result", "success");
			map.put("courseList" ,courseList);
			courseActionImpl.responseStream(response, new ObjectMapper().writeValueAsString(map));
		} catch (Exception e) {
			e.printStackTrace();
			map.put("result", "fail");
			map.put("failMsg", "查询失败");
			logger.error("教师教的所有课程信息getTeacherTeachCourses", e);
			try {
				courseActionImpl.responseStream(response, new ObjectMapper().writeValueAsString(map));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}

	/**
	 * @description 教师教的所有班级信息
	 *   result 结果 success成功fail失败 failMsg失败信息  classList班级列表  classId班级id  className班级名
	 * */
	@RequestMapping(value = "/teacherTeachClasses", method = RequestMethod.POST)
	public void  teacherTeachClasses (HttpServletResponse response, HttpServletRequest request) {
		Map<String, Object> map = new HashMap<String, Object>();
		//日志信息
		Logger logger = Logger.getLogger(MyCourseAction.class.getName());
		try {
			map.put("stuorteaId", new SessionValues().getSessionValues(new String[] {"stuorteaId"}, request, "userMsg").get("stuorteaId"));
			List<Map<String, Object>> classList = homeworkTestActionImpl.getTeaTeachClass(map);
			map.put("result", "success");
			map.put("classList" ,classList);
			courseActionImpl.responseStream(response, new ObjectMapper().writeValueAsString(map));
		} catch (Exception e) {
			e.printStackTrace();
			map.put("result", "fail");
			map.put("failMsg", "查询失败");
			logger.error("教师教的所有班级信息teacherTeachClasses", e);
			try {
				courseActionImpl.responseStream(response, new ObjectMapper().writeValueAsString(map));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}

	/**
	 * @description 查询某人某课的进度信息
	 *   result 结果 success成功fail失败
	 * */
	@RequestMapping(value = "/getMyProcess", method = RequestMethod.POST)
	public void  getMyProcess (HttpServletResponse response, String jsonStr) {
		myCourseActionImpl.getMyProcess(jsonStr, response);
	}

}